package com.sdp.right.db.sys_flow_current_task.service.impl;

import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sdp.right.db.sys_flow_current_task.mapper.SysFlowCurrentTaskMapper;
import com.sdp.right.db.sys_flow_current_task.service.ISysFlowCurrentTaskService;
import com.sdp.right.entity.SysFlowCurrentTask;
import com.sdp.right.service.RemoveSystemService;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zsp
 * @since 2024-07-18
 */
@Service
public class SysFlowCurrentTaskServiceImpl extends ServiceImpl<SysFlowCurrentTaskMapper, SysFlowCurrentTask> implements ISysFlowCurrentTaskService,RemoveSystemService {

	@Override
	public void clearHisFlowCurrentTaskVersion(String version, String templateNo) {
		LambdaQueryWrapper<SysFlowCurrentTask> queryWrapper = new LambdaQueryWrapper<>();
		queryWrapper.ne(SysFlowCurrentTask::getTemplateVersion, version);
		queryWrapper.eq(SysFlowCurrentTask::getTemplateNo, templateNo);
		remove(queryWrapper);
		
	}
	
	@Override
	public void removeApprovalCurrentTask(String instanceId,String nodeId) {
		LambdaQueryWrapper<SysFlowCurrentTask> queryWrapper = new LambdaQueryWrapper<>();
		queryWrapper.eq(SysFlowCurrentTask::getInstanceId, instanceId);
		queryWrapper.eq(SysFlowCurrentTask::getCurrentNodeId, nodeId);
		remove(queryWrapper);
	}
	@Override
	public int queryApprovalCurrentTaskCount(String instanceId, String nodeId) {
		LambdaQueryWrapper<SysFlowCurrentTask> queryWrapper = new LambdaQueryWrapper<>();
		queryWrapper.eq(SysFlowCurrentTask::getInstanceId, instanceId);
		queryWrapper.eq(SysFlowCurrentTask::getCurrentNodeId, nodeId);
		return count(queryWrapper);
	}
	@Override
	public void removeBySystemNo(String systemNo) {
		LambdaQueryWrapper<SysFlowCurrentTask> queryWrapper = new LambdaQueryWrapper<>();
		queryWrapper.eq(SysFlowCurrentTask::getSystemNo, systemNo);
		remove(queryWrapper);
		
	}

	@Override
	public void removeFlowCurrentTaskByInstanceId(String instanceId) {
		LambdaQueryWrapper<SysFlowCurrentTask> queryWrapper = new LambdaQueryWrapper<>();
		queryWrapper.eq(SysFlowCurrentTask::getInstanceId, instanceId);
		remove(queryWrapper);
		
	}
	

}
